package controller

import (
	"smc-admin/models"
	"smc-admin/response"

	"github.com/gin-gonic/gin"
)

// @Tags         用户管理
// @Description  获取当前用户信息
// @Security     ApiKeyAuth
// @Success      200       {object}  models.User
// @Router       /user/get [get]
func GetUserInfo(ctx *gin.Context) {
	id, _ := ctx.Get("id")

	m := models.User{
		BaseModel: models.BaseModel{
			ID: id.(int),
		},
	}

	user, res := m.Find()
	if res != nil {
		panic(res.Error())
	}

	response.Success(ctx, response.Body{
		Data: user,
	})
}
